package com.yami.shop.mystery.common.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yami.shop.bean.model.ShopDealer;
import com.yami.shop.bean.vo.search.MicroreleaseProductSearchVo;
import com.yami.shop.mystery.common.dto.ActivityPresellDto;
import com.yami.shop.mystery.common.dto.ActivityProdDataDto;
import com.yami.shop.mystery.common.dto.ActivityProdDto;
import com.yami.shop.mystery.common.model.ActivityPresell;
import com.yami.shop.mystery.common.vo.ActivityPresellPageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 活动数据接口
 *
 * @author wxf
 * @date 2023/4/12 10:22
 */
@Mapper
public interface ActivityPresellMapper extends BaseMapper<ActivityPresell> {

    /**
     * 预售活动份分页
     *
     * @param dto
     * @return
     */
    List<ActivityPresellDto> pageList(@Param("dto") ActivityPresellPageVo dto);

    /**
     * 同一时间段内，查询商品参加活动列表
     *
     * @param prodId
     * @param activityId
     * @param activityStartTime
     * @param activityEndTime
     * @param activityType
     * @return
     */
    ActivityPresell selectDataByProdIdAndActivityId(@Param("prodId") Long prodId,
                                                    @Param("activityId") Long activityId,
                                                    @Param("activityStartTime") Date activityStartTime,
                                                    @Param("activityEndTime") Date activityEndTime,
                                                    @Param("activityType") String activityType,
                                                    @Param("shopDealerId") Long shopDealerId);

    /**
     * 获取活动时间内的活动列表
     * @return
     * @param prodId
     */
    List<ActivityPresellDto> selectAllActivityPresell(@Param("prodId") Long prodId);

    List<ActivityProdDto> getPutawayProdId();

    /**
     * 获取活动时间内的活动列表通过活动类型
     * @return
     * @param activityType
     */
    List<ActivityPresellDto> selectAllActivityPresellByActivityType(@Param("activityType") Integer activityType);

    List<ActivityPresellDto> selectAllActivityPresellByActivityTypes(@Param("activityTypes")List<Long> activityTypes);

    List<ActivityPresellDto> selectAllActivityPresellByActivityIds(@Param("activityIds") List<String> activityIds, @Param("activityTypes")List<Long> activitys);

    /**
     * 获取商品参与活动的有效活动总库存数
     * @return
     * @param prodId prodId
     */
    Integer selectStocksByProdId(@Param("prodId") Long prodId);

    List<MicroreleaseProductSearchVo> selectPageActivityPresellByActivityIds(@Param("activityIds") List<String> activityIds,@Param("activityTypes") List<Long> activityTypes);

    ActivityProdDataDto getDataByActivityAndProdId(@Param("activityId") Long activityId,@Param("prodId") Long prodId);


    /**
     * 修改库存
     * @param activityId
     * @param prodCount
     * @return
     */
    int updateStocksById(@Param("activityId") Long activityId, @Param("prodCount") Integer prodCount);

    /**
     * 还原库存
     *
     * @param prodCount
     */
    int returnStocks(@Param("activityId") Long activityId, @Param("prodCount") Integer prodCount);

    ActivityProdDataDto getDataByProdIds(@Param("pids")Long pids);

    ShopDealer getDealerByActivityId(@Param("activityId") Long activityId);
}
